<template>
  <fieldset>
    <legend>Child</legend>
    <h1>Child</h1>
    <h2>父组件传参：{{ g }}</h2>
    <h2>兄弟组件传参：{{ gift2 }}</h2>
    <button @click="handleClick">点击传参父组件</button>
  </fieldset>
</template>
<script>
export default {
  props: ["g"],
  data() {
    return {
      gift: "茅台",
      gift2: "",
    };
  },
  mounted() {
    this.$bus.$on("receive", (input) => {
      console.log(input);
      this.gift2 = input;
    });
  },
  methods: {
    handleClick() {
      this.$emit("get", this.gift);
    },
  },
};
</script>
